package livesun.justiceeternal.db.task;

import java.util.ArrayList;
import java.util.List;

public class BaseMsgNotificator<T> {
    private List<T> mListeners = new ArrayList<T>();

    public void registerListener(T listener) {
        if (listener == null) {
            return;
        }

        synchronized (mListeners) {
            if (!mListeners.contains(listener)) {
                mListeners.add(listener);
            }
        }
    }

    public void unRegisterListener(T listener) {
        if (listener == null) {
            return;
        }

        synchronized (mListeners) {
            if (mListeners.contains(listener)) {
                mListeners.remove(listener);
            }
        }
    }

    public List<T> getListeners() {
        return new ArrayList<T>(mListeners);
    }
}
